package com.icinfo.cloud.provider.peripheralinterface.xzzf.controller;

import com.icinfo.cloud.provider.peripheralinterface.xzzf.dto.LawEnforcementCertQueryDto;
import com.icinfo.cloud.provider.peripheralinterface.xzzf.service.IXzzfInterfaceService;
import com.icinfo.framework.common.web.Result;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 描述：行政执法接口前端控制器
 *
 * @author xiangyuyu
 * @date 2022/5/18 10:49
 */
@RestController
@RefreshScope
@RequestMapping("/peripheralInterface/xzzf")
@Slf4j
public class XzzfInterfaceController {
    @Resource
    private IXzzfInterfaceService xzzfInterfaceService;

    /**
     * 【V2.0.0】描述：获取执法证编号信息
     *
     * @param queryDto 查询dto
     * @return {@link Result<String> }
     * @author shishengyao
     * @date 2022/07/15
     */
    @PostMapping("getLawEnforcementCertWithUserId")
    @ApiOperation(value = "【V2.0.0】描述：获取执法证编号信息", httpMethod = "POST")
    public Result<String> getLawEnforcementCertWithUserId(@RequestBody @Validated LawEnforcementCertQueryDto queryDto) {
        String enforcementCert = xzzfInterfaceService.getLawEnforcementCertWithUserId(queryDto.getUserId());
        if (ObjectUtils.isEmpty(enforcementCert)) {
            return Result.error("当前人员未匹配到有效的执法证号");
        } else {
            return Result.success(enforcementCert);
        }
    }
}
